package com.homedo.odin.solution.enumcode;

import org.apache.commons.lang.ArrayUtils;

public enum BrandStatusEnum {

    PENDINGAUDIT(10, "待专家审核"), AUDITSUCCESS(20, "审核通过"), AUDITFAIL(21, "审核驳回");

    private int key;
    private String value;

    private BrandStatusEnum(int key, String value) {
        this.value = value;
        this.key = key;
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public static Integer getKey(String name) {
        int key = 0;
        for (BrandStatusEnum e : BrandStatusEnum.values()) {
            key = e.getKey();
            if (getName(key).equals(name)) {
                return key;
            }
        }
        return 0;
    }

    // 普通方法
    public static String getName(int key) {
        for (BrandStatusEnum e : BrandStatusEnum.values()) {
            if (e.getKey() == key) {
                return e.value;
            }
        }
        return null;
    }

    public static boolean validateType(int type) {
        return ArrayUtils.contains(new int[]{PENDINGAUDIT.getKey(), AUDITSUCCESS.getKey(),
                AUDITFAIL.getKey()}, type);
    }

}
